<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Edit Item</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 0;
        }

        h1 {
            text-align: center;
            color: #333;
            margin-top: 30px;
        }

        form {
            background-color: #fff;
            max-width: 400px;
            margin: 30px auto;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }

        label {
            display: block;
            margin-bottom: 5px;
            color: #555;
        }

        input[type="text"],
        input[type="number"] {
            width: 100%;
            padding: 10px;
            margin-bottom: 15px;
            border: 1px solid #ccc;
            border-radius: 3px;
            box-sizing: border-box;
        }

        button {
            background-color: #007BFF;
            color: #fff;
            padding: 10px 20px;
            border: none;
            border-radius: 3px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }

        button:hover {
            background-color: #0056b3;
        }

        a {
            display: block;
            text-align: center;
            color: #007BFF;
            text-decoration: none;
            margin-top: 10px;
        }

        a:hover {
            text-decoration: underline;
        }

        table {
            width: 80%;
            margin: 20px auto;
            border-collapse: collapse;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }

        th, td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }

        th {
            background-color: #007BFF;
            color: white;
        }

        tr:hover {
            background-color: #f5f5f5;
        }

        td a {
            display: inline;
            margin-right: 10px;
        }
    </style>
</head>
<body>
    <h1>物料编辑</h1>
    <form method="post" action="/update/material/{{ item.item_id }}">
        <label for="name">名称:</label>
        <input type="text" id="name" name="name" value="{{ item.name }}" required><br>
        <label for="price">规格:</label>
        <input type="text" id="spec" name="spec" step="0.01" value="{{ item.spec }}" required><br>
        <label for="unit">单位:</label>
        <input type="text" id="unit" name="unit" value="{{ item.unit }}"><br>
        <label for="price">单价:</label>
        <input type="number" id="price_per_unit" name="price_per_unit" step="0.01" value="{{ item.price_per_unit }}"><br>
        <button type="submit">更新</button>
    </form>
    <h1>所有物料规格</h1>
    <table>
        <thead>
            <tr>
                <th>物料ID</th>
                <th>名称</th>
                <th>规格</th>
                <th>单位</th>
                <th>单价</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {% for material in material_spec_items %}
            <tr>
                <td>{{ material.item_id }}</td>
                <td>{{ material.name }}</td>
                <td>{{ material.spec }}</td>
                <td>{{ material.unit }}</td>
                <td>{{ material.price_per_unit }}</td>
                <td>
                    <a href="/edit/material/{{ material.item_id }}">编辑</a>
                    <a href="/delete/material/{{ material.item_id }}">删除</a>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</body>
</html>
